<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input
          v-model="query.nickname"
          clearable
          placeholder="昵称"
          style="width: 185px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        style="width: 100%;"
        stripe
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="memberId" label="充值用户id"       />
        <el-table-column prop="nickname" label="昵称"       />
        <el-table-column prop="orderId" label="订单号"       />
        <el-table-column prop="paid" label="是否充值"       />
        <el-table-column prop="payTime" label="充值支付时间"       />
        <el-table-column prop="price" label="充值金额"       />
        <el-table-column prop="rechargeType" label="充值类型"       />
        <el-table-column prop="refundPrice" label="退款金额"       />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMemberRecharge from '@/api/ums/memberRecharge'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'

const defaultForm = {
  memberId: null,
  nickname: null,
  orderId: null,
  paid: false,
  payTime: null,
  price: null,
  rechargeType: 0,
  refundPrice: null
}
export default {
  name: 'MemberRecharge',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: '充值记录',
      url: 'memberRecharge/page',
      sort: 'id:desc',
      crudMethod: { ...crudMemberRecharge },
      optShow: { }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'memberRecharge:add'],
        edit: ['admin', 'memberRecharge:edit'],
        del: ['admin', 'memberRecharge:del']
      },
      rules: {
        memberId: [
          { required: true, message: '充值用户id不能为空', trigger: 'blur' }
        ],
        orderId: [
          { required: true, message: '订单号不能为空', trigger: 'blur' }
        ],
        price: [
          { required: true, message: '充值金额不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'nickname', display_name: '昵称' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
